<template>
  <div id="cart-item">
    <input
      class="checkbox"
      type="checkbox"
      name="test1"
      :checked="cart_info.isChecked"
      :value="cart_info.id"
      @change="itemClick(cart_info.id, $event)"
    />
    <div class="info">
      <img
        class="img-info"
        v-lazy="cart_info.image"
      />
      <div class="goods-info">
        <div class="goods-name">{{ cart_info.title }}</div>
        <div class="goods-desc">{{ cart_info.desc }}</div>
        <div class="goods-fee">
          <span class="price">￥{{ cart_info.price }}</span>
          <span class="count">X{{ cart_info.count }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    cart_info: {
      type: Object,
      default() {
        return {}
      },
    },
  },
  data() {
    return {}
  },
  methods: {
    itemClick(id, event) {
      this.$store.commit('changeCartListChecked', {
        id,
        isChecked: event.target.checked,
      })
    },
  },
}
</script>

<style lang="less" scoped>
#cart-item {
  display: flex;
  height: 120px;
  padding: 10px;
  border-bottom: 1px solid #eeeeee;
  .checkbox {
    margin-right: 20px;
    height: 100%;
  }
  .info {
    display: flex;
    .img-info {
      flex: 1;
      height: 100%;
      border-radius: 8px;
    }
    .goods-info {
      flex: 3;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      padding-left: 10px;
      .goods-name {
        font-size: 16px;
      }
      .goods-desc {
        color: #999999;
      }
      .goods-fee {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        .price {
          font-size: 16px;
          font-weight: bold;
          color: @base-color;
        }
      }
    }
  }
}
</style>
